package cn.ekuma.epos.crm.dialog;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.JButton;
import javax.swing.JPanel;
import cn.ekuma.swing.dialog.AbstractKeyBoardJDialog;

import com.openbravo.pos.base.AppLocal;
import com.openbravo.pos.panels.JStringRangeGeneratPanel;

public class JCardNumBatchCreateDialog extends AbstractKeyBoardJDialog{

	JStringRangeGeneratPanel storeCardValueOp;
	/**
	 * @wbp.parser.constructor
	 */
	public JCardNumBatchCreateDialog(Dialog parent, boolean modal) {
		super(parent, modal);
		initComponents();
	}


	public JCardNumBatchCreateDialog(Frame parent, boolean modal) {
		super(parent, modal);
		initComponents();
	}
	
	public static JCardNumBatchCreateDialog newJDialog(Component superComp) {
        Window window = getWindow(superComp);
        JCardNumBatchCreateDialog mydialog;
        if (window instanceof Frame) {
            mydialog = new JCardNumBatchCreateDialog((Frame) window, true);
        } else {
            mydialog = new JCardNumBatchCreateDialog((Dialog) window, true);
        }
        mydialog.init();
        mydialog.applyComponentOrientation(superComp.getComponentOrientation());
        return mydialog;
    }
	
	
	private void init() {
		storeCardValueOp=new JStringRangeGeneratPanel();
		getContentPane().add(storeCardValueOp, BorderLayout.CENTER);
	}
	
	private void initComponents() {
		JPanel panel = new JPanel();
		getContentPane().add(panel, BorderLayout.SOUTH);
		panel.setLayout(new FlowLayout(FlowLayout.RIGHT));
		
		JButton button = new JButton(AppLocal.getIntString("Button.OK"));
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				enterKeyProc();
			}
		});
		panel.add(button);
		
		JButton button_1 = new JButton(AppLocal.getIntString("Button.Close"));
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				escapeKeyProc();
			}
		});
		panel.add(button_1);
		java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-580)/2, (screenSize.height-400)/2, 465, 396);
		
	}
	
	@Override
	protected void enterKeyProc() {
	      dispose();
	}

	@Override
	protected void escapeKeyProc() {
		dispose();
		
	}

	@Override
	protected void upKeyProc() {

	}

	@Override
	protected void downKeyProc() {

	}
    
	public ArrayList<String> getStringList(){
		return storeCardValueOp.getListString();
	}
	
	public void resert(){
		storeCardValueOp.reset();
	}
	
	
}

